package com.lance.answer.gui.answer.gk.video.tmp.tmp;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lance.answer.gui.answer.Util;
import com.lance.answer.gui.answer.gk.DealInfoUtil;
import com.lance.answer.gui.answer.gk.answer.AnswerDTO;
import com.lance.answer.gui.answer.gk.answer.task.UploadFileTask;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;

@Slf4j
public class UploadFileTmpppppp {

    /**
     * 进度表：
     * 6-18 19:55开始测试 公共行政学 行政管理专科
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        int sync = 12;
     //   Thread.sleep(1000*60*60*1);
       // Thread.sleep(1000*60*60*9);
        Map<String,List<String>> all = Maps.newHashMap();
        all.put("计算机应用基础",Lists.newArrayList("http://xinjiang.ouchn.cn/mod/assign/view.php?id=244498"));

        LinkedBlockingDeque<AnswerDTO> answerQueue = new LinkedBlockingDeque<>();

        for(String subjectName:all.keySet()){
            //  LinkedList<AnswerRequestDTO> requestUrl = Lists.newLinkedList();
            LinkedList<String> requestUrl = Lists.newLinkedList(all.get(subjectName));

            log.info("subjectName:{}",subjectName);

            //     InputStream inputStream2 = new FileInputStream("d:\\0103.user");
            InputStream inputStream2 = new FileInputStream("d:\\0104"+subjectName+".user");
            List<String> users = IOUtils.readLines(inputStream2, "utf-8");
            for(String user:users){
                String[] strs = user.split(",");
                String userCode = strs[0];
                String pwd = strs[1].substring(6, 14);
                pwd = "Ouchn" + pwd;
                AnswerDTO answerDTO = new AnswerDTO();
                answerDTO.setSubjectName(subjectName);
                answerDTO.setUsername(userCode);
                answerDTO.setPwd(pwd);
                answerDTO.setCommit(true);
                answerDTO.setPush(false);
                answerDTO.setUploadUrl(requestUrl);
                answerQueue.add(answerDTO);
            }


        }


        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new UploadFileTasktmpppppppppppp(null,answerQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName( "答题线程--" + i);
            answerThread.start();
        }


    }






}
